package com.irssproject.app.web.action.lectorRSS;

import java.util.Map;
import java.util.logging.Logger;

import org.apache.struts2.interceptor.SessionAware;

import com.irssproject.app.service.lectorRSS.iface.SubscriptionsService;
import com.irssproject.app.utils.Constants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class RSSReaderAction extends ActionSupport implements SessionAware {

    private static final long serialVersionUID = -1907995298880332913L;
    static final Logger logger = Logger.getLogger(RSSReaderAction.class.getName());
    SubscriptionsService subscriptionsService;

    public RSSReaderAction(SubscriptionsService subscriptionsService) {
        this.subscriptionsService = subscriptionsService;
    }
    private Map<String, Object> session;

    public void setSession(Map<String, Object> arg0) {
        session = arg0;
    }

    public Map<String, Object> getSession() {
        return session;
    }

    public String mostrarLectorPrincipal() {

        try {
            session = ActionContext.getContext().getSession();
            if (session.containsKey(Constants.SESSIO_USUARI_AUTENTICAT)) {
                logger.info("Inicialitzant l'espai de lectura");
                session.put(Constants.LECTURA_ANTERIOR, null);
                session.put(Constants.COMPTADOR_TEMPS, null);
            }
        } catch (Exception e) {
            logger.info(e.getMessage());
        }

        return SUCCESS;
    }
}
